package com.odata.springboot.starter.odata.odata.config;


import com.odata.springboot.starter.odata.odata.sql.sqlBuild.OdataClassMetaData;
import com.odata.springboot.starter.odata.odata.sql.sqlBuild.enums.DataBaseProductEnum;
import org.apache.olingo.commons.api.edm.provider.CsdlEntitySet;
import org.apache.olingo.commons.api.edm.provider.CsdlEntityType;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

/**
 *
 * odata 缓存的数据  在一开始就加载了
 * @author chenYX
 * @date 2021/6/30 17:10
 * @description
 */
public class OdataCachedData {
    /**
     * edmEntitySet 集合
     */
    public static final Set<Class<?>> emdEntitySet = new HashSet<>();
    /**
     * 类全名 与 CsdlEntityType 的映射关系
     */
    public static final Map<String, CsdlEntityType> cachedCsdlEntityTypeMap = new HashMap<>();
    /**
     * 类全名 与 类的元数据的映射关系
     */
    public static final Map<String, OdataClassMetaData> cachedCsdlMetaDataMap = new HashMap<>();

    /**
     * simpleName+s 与 CsdlEntitySet的映射关系
     */
    public static final Map<String, CsdlEntitySet> cachedCsdlEntitySetMap = new HashMap<>();

    /**
     * 数据库类型
     */
    public static DataBaseProductEnum dataBaseProductEnum;

    /**
     * 依据edmClass获取类信息
     * @author : yongxiang
     * @description :
     * @param
     * @date : 9:35 2021/7/2
    */
    public static OdataClassMetaData getClassMetaDataByClass(Class aClass){
        if (aClass == null){
            return null;
        }
        return OdataCachedData.cachedCsdlMetaDataMap.get(aClass.getName());
    }

}
